package main

import (
	"flag"
	"fmt"
)

func main() {
	//定义变量，接受命令行参数
	var user string
	var pwd string
	var host string
	var port int

	flag.StringVar(&user, "u", "", "用户名默认为空")
	flag.StringVar(&pwd, "pwd", "", "密码默认为空")
	flag.StringVar(&host, "h", "localhost", "主机名默认为localhost")
	flag.IntVar(&port, "u", 3306, "端口号默认为3306")

	//转换，必须调用
	flag.Parse()
	fmt.Printf("user=%v pwd=%v  host=%v  port=%v", user, pwd, host, port)

}
